package cn.yyt.yytravel.guide.controller;

import cn.yyt.yytravel.base.response.JsonResult;
import cn.yyt.yytravel.guide.pojo.dto.GuideInfo;
import cn.yyt.yytravel.guide.pojo.dto.SaveGuideForm;
import cn.yyt.yytravel.guide.pojo.vo.GuideReviewsVO;
import cn.yyt.yytravel.guide.pojo.vo.GuideVO;
import cn.yyt.yytravel.guide.service.GuideService;
import cn.yyt.yytravel.guide.service.ReviewService;
import cn.yyt.yytravel.like.pojo.vo.LikeUserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/yyt/guide/")
public class GuideController {
    @Autowired
    GuideService guideService;
    
    @Autowired
    ReviewService reviewService;

    @GetMapping("select")
    public JsonResult loadGuide(){
        List<GuideVO> list = guideService.loadGuide();
        log.debug("导出的数据{}",list);
        return JsonResult.ok(list);
    }
    @PostMapping(value = "save")
    public JsonResult saveGuide(SaveGuideForm saveGuideForm){
        System.out.println("saveGuideForm = " + saveGuideForm);
        //添加数据
      guideService.saveGuide(saveGuideForm);
        return JsonResult.ok();
    }

    //获取导游的信息。你觉得呢？
    @GetMapping(value = "selectOrder")
    public JsonResult selectGuide(){
        List<GuideVO> list = guideService.selectGuide();
        log.debug("{}",list);
        return JsonResult.ok(list);
    }

    //游客评价分数
    @PostMapping(value = "reviews")
    public JsonResult insertReviews(GuideInfo guideInfo){
        log.debug("评价数据是：{}",guideInfo);
        reviewService.insertReviews(guideInfo);
        return JsonResult.ok();
    }
    
    //查询是否已评价
    @GetMapping(value = "reviews/status")
    public JsonResult selectReviews(@RequestParam Long touristId,@RequestParam Long guideId){
        log.debug("有信息吗？{},{}",touristId,guideId);
//        GuideReviewsVO guideReviewsVO =  reviewService.selectReviews(touristId,guideId);
        return JsonResult.ok();
    }
}
